package de.iritgo.skillfull.component.visitor;

import de.iritgo.skillfull.component.visual.SimpleTextComponent;

/**
 * Configure a simple text component
 * 
 * @author held
 * 
 */
public class SimpleTextVisitor extends BaseVisitor 
{
	private boolean done;
	private boolean setText;
	private float timeOnScreen;
	private String text;
	private int special;

	
	public SimpleTextVisitor (String text, float timeOnScreen)
	{
		this.done = false;
		this.setText = true;
		this.text = text;
		this.timeOnScreen = timeOnScreen;
	}
	
	public SimpleTextVisitor(int special) 
	{
		this.special = special;
	}

	public boolean isDone ()
	{
		return done;
	}

	public void visit (SimpleTextComponent simpleTextComponent)
	{
		if (special == 1)
		{
			simpleTextComponent.removeText ();
			done = true;
			return;
		}
		
		if (setText)
		{
			simpleTextComponent.showText(text, timeOnScreen);
			setText = false;
		}
		
		done = simpleTextComponent.isDone ();
	}
}
